#include "../inc/main_interface.h"
#include "../inc/bmp.h"
#include "../inc/touch.h"
#include "../inc/registerLogin.h"
#include "../inc/my_game.h"
#include "../inc/my_picture.h"
#include "../inc/my_brush.h"

#include "../inc/test.h"//这两个都是实现字库引入的
#include "../inc/lcd.h"

void main_show(char* user){
    //显示主界面
    bmp_show("./res/interface/mainBackground.bmp",0,0);
    //玩家XXX进入主界面
    main_font_library(0,0,user);
    //让龙猫妹妹循环跳动

    //显示游戏图标
    bmp_show_small("./res/interface/mainGame.bmp", 20, 340);
    //显示相册图标
    bmp_show_small("./res/interface/mainPicture.bmp", 140, 340);
    //显示画笔
    bmp_show_small("./res/interface/mainBrush.bmp", 260, 340);
    //显示退出
    bmp_show_small("./res/interface/mainExit.bmp", 690, 340);
}

int main_touch_icon(){
    int x = 0;
    int y = 0;
     while(1){
        //获取按键上的坐标
        touch_wait(&x,&y);
        if(PLACE_GAME(x,y)){
            printf("点击了game\n");
            return GAME_BUTTON;
        }
        if(PLACE_PICTURE(x,y)){
            printf("点击了picture\n");
            return PICTURE_BUTTON;
        }
        if(PLACE_BRUSH(x,y)){
            printf("点击了brush\n");
            return BRUSH_BUTTON;
        }
        if(PLACE_EXIT(x,y)){
            printf("点击了exit\n");
            return MAIN_EXIT_BUTTON;
        }
    }
}

void main_exit(){
    //点击主界面退出，退回到登陆注册界面

}

int while_main_touch(char* user){
    while(1){
        int select_num;
        //进入主界面
        main_show(user);
        //主界面的点击
        select_num = main_touch_icon();
        switch (select_num)
        {
        case GAME_BUTTON:
            //进入游戏的界面显示
            bmp_show("./res/interface/main_to_game.bmp",0,0);
            bmp_show_small("./res/interface/logo.bmp",0,0);
            time_prograss_bar();
            //游戏界面的搭建
            game_show();
            //游戏内的相关逻辑
            game_play();
            //显示返回主界面的画面
            bmp_show("./res/interface/game_to_main.bmp",0,0);
            bmp_show_small("./res/interface/logo.bmp",0,0);
            time_prograss_bar();
            break;
        case PICTURE_BUTTON:
            //进入相册的界面显示
            bmp_show("./res/interface/main_to_picture.bmp",0,0);
            bmp_show_small("./res/interface/logo.bmp",0,0);
            time_prograss_bar();
            //相册界面的搭建
            picture_show();
            //相册内的相关逻辑
            picture_background_touch(user);
            break;
        case BRUSH_BUTTON:
            //做查看用户保存图片的模块
            bmp_show("./res/interface/main_to_brush.bmp",0,0);
            bmp_show_small("./res/interface/logo.bmp",0,0);
            time_prograss_bar();
            //查看文件截图的相关逻辑
            view_file_screenshot(user);

            break;
        case MAIN_EXIT_BUTTON:
        
            return MAIN_EXIT_BUTTON;
        }
    }
}

